#ifndef TIMER_H
#define TIMER_H

#define DECREASING false
#define INCREASING true

#include "timemanager.h"

//It's a choronometer or a backcount
class Timer
{
	public:
		Timer():time(0.0),growing(DECREASING){}
		~Timer(){shutdown();}

		//Initialiced the counter like choronometer
		void start();
		//Initialiced the counter like backcount
		void countdown(const float at);

		void update();

		//it modifies the time
		void setTime(const float at){time=at;}
		void addTime(const float at){time+=at;}
		void delTime(const float at){time-=at;}

		//Ends the timer
		void shutdown(){t->update(); t->delTimer(this);}

		//return time left
		float getTime()const{return time;}
		int getSeconds()const{return (int)time%60;}
		int getMinutes()const{return (int)time/60;}

		//if the counter is paused you can resume
		void resume(){t->update(); t->addTimer(this);}
		bool isEnd(){return time<=0;}

		static void setTimeManager(TimeManager* at){t=at;}

	private:
		float time;
		bool growing;
		static TimeManager* t;
};

#endif
